<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Details du factures</title>


<!---------------------for autocomplete--------------->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-1.11.0.min.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/jquery-ui.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form css ----------------------->
	<link href="<?php echo base_url("assets/css/pure.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form validation ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.validate.js');?>" ></script>
<!---------------------for form mask input ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.mask.min.js');?>" ></script>


</head>
<body>
<?php
include_once('header.php');
$r1=$fournisseur;  // one fournisseur
$r2=$liste_fourn;  // list of all fournisseur for autocomplete
$r3=$liste_article; // list of all activities for auto complete

// ----- populate $liste_des_fournisseurs array for autocomplete ----- //
$liste_des_fournisseurs = array();
foreach ($r2 as $lf){
	array_push($liste_des_fournisseurs, $lf->nom);
}
// ----- populate $liste_des_activites array for autocomplete ----- //
$liste_des_articles = array();
foreach ($r3 as $lda){
	array_push($liste_des_articles, $lda->nom_art);
	
}

?>
<?php
echo form_open_multipart( base_url('facture_ctr/update').'/'.$r1[0]->id_facture ); 
?>

<form id="fournisseur_frm" class="pure-form pure-form-stacked" method="POST" action="<?php echo base_url('facture_ctr/update').'/'.$r1[0]->id_facture ;?>">
    <fieldset>
        <legend>رقم الفاتورة: <?php echo('<strong>'.$r1[0]->numero.'</strong>');?></legend>

        <div class="pure-g">
            <div class="pure-u-1 pure-u-md-1-3">
                <label for="fournisseur">المورد : </label>
				<label><?php echo($r1[0]->fournisseur);?></label>
            </div>

          

            <div class="pure-u-1 pure-u-md-1-3 ">
                <label for="mondat">حوالة الدفع </label>
                <label><?php echo($r1[0]->num_mondat);?></label>
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3">
                <label for="address">المبلغ : </label>
                <label><?php echo($r1[0]->montant_fact);?></label>
            </div>
			
			
			
		<!--	<div class="pure-u-1 pure-u-md-1-3">
                <label for="rc"> الصورة  </label>
                <input  class="ltr" id="imgae" name="image" type="text"  placeholder="00/00-00000(0000)A00" value="<?php echo($r1[0]->image);?>">
				<input type="file" name="userfile" size="20" />
            </div>-->
			
			
			
			
			<div class="pure-u-1 pure-u-md-1-3" style="width: 90%">
                <label for="notes"> <?php echo($lettre);?> </label>
               
            </div>
			
        </div>
<?php
  $goupe=$this->session->userdata('user_group'); //access it
if($goupe=="admin"){
echo ('
<a href="'. base_url('facture_ctr/index_test').'" class="pure-button pure-button-primary">خروج</a>
');
}else{
	echo ('
	<a href="'. base_url('facture_ctr/index_test').'" class="pure-button pure-button-primary">خروج</a>');
}
?>
 <a <?php echo(' href=" '.base_url('facture_ctr/supprimer_facture').'/'.$r1[0]->id_facture.' " ');?> class="pure-button pure-button-primary" onclick="return confirm('هل تريد فعلا حذف هذه الفاتورة ');">حذف</a>
     <!-- <input type="submit" value="Envoyer"  class="pure-button pure-button-primary" />-->

    
    </fieldset>
</form>

<?php  
if($goupe=="finance"){ // si il est comtable on affiche des bottons
  if($r1[0]->num_mondat==NULL)
	 echo '
 <div>
 <form id="bc_form"  method="POST" action="'.base_url('facture_ctr/payer_facture').'/'.$r1[0]->id_facture.'">
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 90%; text-align: center; letter-spacing:0.5px; font-size:150%">
                <label for="numero" > خاص بالمحاسب</label>
			
                
            </div>
			
			
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 90%">
                <label for="numero"> رقم الصك </label>
				<input class="ltr" id="dessignation" name="num_cheque" type="text" value="">
                
            </div>
			
			
			
			<div  class="pure-u-1 pure-u-md-1-3" " style="width: 90%">
		<input type="submit" id="ajouter" value="دفع"  class="pure-button pure-button-primary"  />
	 
			 </div>
			 </form>
			 </div>
			';
			
	}
	
	?>
	
</body>
<script>
$(function() {
	

var liste_fourniss = <?php echo json_encode($liste_des_fournisseurs); ?>;
var liste_article = <?php echo json_encode($liste_des_articles); ?>;

$( "#nom" ).autocomplete({source: liste_fourniss});
$( "#article" ).autocomplete({source: liste_article});


});

//---

$('#submit_btn').click(function() {
  if($("[class^=error]").is(":visible")){
    alert('منالك حقل / حقول إدخال غير مطابقة !');
    return false;
  } else {
  	$('#fournisseur_frm').submit();
    return false;
  }
});


$('#numero').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-rc').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    //var characterReg = /^([a-zA-Z0-9]{7,16})$/;
    var characterReg = /^([0-9]{1,3})$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-rc" flag="required" style="color:red;" >حقل غير مطابق للشكل العام </span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});
$('#mondat').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-rc').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    //var characterReg = /^([a-zA-Z0-9]{7,16})$/;
    var characterReg = /^([0-9]{1,3})$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-rc" flag="required" style="color:red;" >حقل غير مطابق للشكل العام </span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});




//---* maskage below 
$('#numero').mask('AAA', {'translation': {
                                        A: {pattern: /[0-9]/},
										O: {pattern: /[0-9]/, optional: true},
										D: {pattern: /[a-zA-Z]/}
                                      }
                                });

//---* maskage below 
$('#mondat').mask('AAA', {'translation': {
                                        A: {pattern: /[0-9]/},
										O: {pattern: /[0-9]/, optional: true},
										D: {pattern: /[a-zA-Z]/}
                                      }
                                });





</script>
</html>